package cn.heygod.nacostool.util;

import java.util.List;

/**
 * @Author Simon
 */
public class StrUtil {

//
//    public static String asStr(List list){
//        StringBuilder sb = new StringBuilder();
//        for (Object item :
//                list) {
//            if(sb.length()>0){
//                sb.append(",");
//            }
//            sb.append(item);
//        }
//        return sb.toString();
//    }

    /**
     * "instanceId": "0.0.0.0#9001#DEFAULT#demo_group@@nacos-service",
     * "instanceId": "0.0.0.0#9001#DEFAULT#DEFAULT_GROUP@@demo-service-name",
     * @return
     */
    public static String parseServiceNameById(String instanceId){
        int index = instanceId.indexOf("@@");
        if(index == -1){
            throw new RuntimeException("instanceId format error:"+instanceId+",like :0.0.0.0#9001#DEFAULT#DEFAULT_GROUP@@demo-service-name");
        }
        return instanceId.substring(index+2);
    }

}
